package com.gmall.product.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gmall.common.result.Result;
import com.gmall.model.product.BaseTrademark;
import com.gmall.product.service.BaseTrademarkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("admin/product/baseTrademark")
public class BaseTrademarkController {

    @Autowired
    BaseTrademarkService trademarkService;

    @GetMapping("{pageNo}/{pageSize}")
    public Result<Page<BaseTrademark>> findPage(@PathVariable Long pageNo, @PathVariable Long  pageSize,
                                             @RequestBody(required = false) String body) {

        return trademarkService.findPage(pageNo,pageSize);
    }

    @PostMapping("save")
    public Result<String> save(@RequestBody BaseTrademark baseTrademark){

        //int i = 10/0;
        return trademarkService.save(baseTrademark);
    }

    @DeleteMapping("remove/{id}")
    public Result<String> remove(@PathVariable Long id){
        return trademarkService.remove(id);
    }

    @PutMapping("update")
    public Result<String> update(@RequestBody BaseTrademark baseTrademark){
        return trademarkService.update(baseTrademark);
    }

    @GetMapping("get/{id}")
    public Result<BaseTrademark> get(@PathVariable Long id){
        Result<BaseTrademark> baseTrademarkResult = trademarkService.get(id);
        return baseTrademarkResult;
    }
}
